package com.example.drawscreen;

import android.app.IntentService;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.LinearLayout;
import android.widget.Toast;

public class FingersService extends Service implements OnTouchListener {

	public FingersService() {
	}
	
	private LinearLayout touchLayout;

	@Override
	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public void onCreate() {
		Toast.makeText(this, "Service was Created", Toast.LENGTH_LONG).show();
		super.onCreate();
		touchLayout = new LinearLayout(this);
		
		Log.d("QUYYYYYYYYYYYYYYYYY", "Service was Created");
	}
	
	@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        // Let it continue running until it is stopped.
        Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
        
        FingerBroadcastReceiver fingerReceiver = new FingerBroadcastReceiver();
        
        
        Log.d("QUYYYYYYYYYYYYYYYYY", "Service was Worked");
        return START_STICKY;
    }
	
	
	
	@Override
	public void onDestroy() {
		Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();
		Log.d("QUYYYYYYYYYYYYYYYYY", "Service was Stoped");
		super.onDestroy();
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		Log.d("QUYYYYYYYYYYYYYYYYY", "Co Event ngon tay o glocal " + event.getAction());
		if(event.getAction() == 261) {
        	Log.d("QUYYYYYYYYYYYYYYYYY", "Co Event 2 ngon o glocal " + event.getAction());
    	}
    	if(event.getAction() == 517) {
        	Log.d("QUYYYYYYYYYYYYYYYYY", "Co Event 3 ngon o global " + event.getAction());
    	}
    	if(event.getAction() == 773) {
        	Log.d("QUYYYYYYYYYYYYYYYYY", "Co Event 4 ngon o global " + event.getAction());
    	}
		return false;
	}
}
